﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataLib.Accounts.Bus;
using System.Data;


namespace Ewts.PD
{
    public partial class PDBarOuts : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                bindMonth();
                User curUser = new User();
                curUser = (User)Session["UserInfo"];
                hidOper.Value = curUser.UserName;

                if (Request["outid"] != null && Request["outid"].ToString().Trim() != "")
                {
                    hidoutid.Value = Request["outid"].ToString().Trim();
                    DataLib.Model.OutStorage model = new DataLib.BLL.OutStorage().GetModel(Convert.ToInt32(hidoutid.Value));
                    hidbcity.Value = model.inDepart;
                    hidgcity.Value = model.OutDepart;
                    txtOutsNo.Value = model.outStorageNo;
                    bindData(hidoutid.Value);
                }
            }

        }

        /// <summary>
        /// 绑定财务结算月
        /// </summary>
        protected void bindMonth()
        {
            int year = DateTime.Now.Year;

            ListItem listitem = new ListItem((year + 1).ToString() + "年", (year + 1).ToString());
            dropYear.Items.Add(listitem);
            listitem = new ListItem(year.ToString() + "年", year.ToString());
            dropYear.Items.Add(listitem);
            listitem = new ListItem((year - 1).ToString() + "年", (year - 1).ToString());
            dropYear.Items.Add(listitem);

            dropYear.SelectedValue = year.ToString();
            dropMonth.SelectedValue = DateTime.Now.Month.ToString().PadLeft(2, '0');

        }

        /// <summary>
        /// 绑定出库明细
        /// </summary>
        /// <param name="outid"></param>
        protected void bindData(string outid)
        {
            DataLib.BLL.OutStorage bllOuts = new DataLib.BLL.OutStorage();
           
            if (outid != null && outid.Trim() != "0")
            {
                DataTable dt = new DataLib.BLL.BarCode().GetList("OutStrorageID=" + outid).Tables[0];
                if (dt != null)
                {
                    rept.DataSource = dt;
                    rept.DataBind();
                }
            }
        }
    }
}